import { BeforeApplicationShutdown, Module, OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
import { CccService } from './ccc.service';
import { CccController } from './ccc.controller';
import { log } from 'console';
import { ModuleRef } from '@nestjs/core';

@Module({
  controllers: [CccController],
  providers: [CccService],
})
export class CccModule implements OnModuleInit, OnApplicationBootstrap, BeforeApplicationShutdown {

  constructor(private moduleRef: ModuleRef) {}

  onModuleInit() {
    console.log('cccModule OnModuleInit');
  }

  onApplicationBootstrap() {
    const cccService = this.moduleRef.get<CccService>(CccService);
    log('----------------------', cccService.findAll())
    console.log('cccModule OnApplicationBootstrap');
  }

  beforeApplicationShutdown(signal?: string) {
    log('cccModule', signal);             
  }
}
